package org.dulong.dao.impl;

import org.dulong.dao.UserInfoDao;
import org.dulong.domain.UserInfo;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-9-23
 * Time: 下午3:17
 * To change this template use File | Settings | File Templates.
 */
public class UserInfoDaoImpl extends HibernateDaoSupport implements UserInfoDao {
    @Override
    public void save(UserInfo userInfo) {
        this.getHibernateTemplate().save(userInfo);
    }

    @Override
    public UserInfo findByName(String username) {
        List<UserInfo> list = this.getHibernateTemplate().find("select u from UserInfo u where u.username = ?", username);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
}
